<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script src="../js/jquery.min.js"></script>

    <script>

        function Ajax(url, data, type) {

            return new Promise((resolve) => {
                $.ajax({
                    url,
                    data,
                    dataType: 'json',
                    type,
                    success: res => {
                        resolve(res)
                    }
                })
            })
        }


        // Ajax('http://localhost/wh2212/day26/%e8%af%be%e5%a0%82%e4%bb%a3%e7%a0%81/php/06login.php', {
        //     username: 'yy',
        //     password: '123'
        // }, 'get').then(res => {
        //     console.log(res)
        // })


        const login = data => Ajax('http://localhost/wh2212/day26/%e8%af%be%e5%a0%82%e4%bb%a3%e7%a0%81/php/06login.php', data, 'get');




        // login({
        //     username: 'yy',
        //     password: '123'
        // }).then(res => {
        //     console.log(res)
        // })



        async function fn(cb) {
            const res = await login({ username: 'yy', password: '123' });
            console.log(res);
            cb && cb()
        }

        fn(function () {
            console.log(222)
        })



    </script>

</body>

</html>